﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using Common.Data;

namespace XMLSQL.Admin
{
    public partial class DeleteUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUserCollection members = Membership.GetAllUsers();
            members.Remove(User.Identity.Name);
            foreach (MembershipUser u in members)
            {
                deleteListBox.Items.Add(u.UserName);
            }
        }

        protected void deleteButton_Click(object sender, EventArgs e)
        {
            //delete the user's connection strings
            IAdminDataProvider adminDb = new AdminDataProvider();
            adminDb.DeleteConnectionStringsByUser(deleteListBox.SelectedItem.Text);

            Membership.DeleteUser(deleteListBox.SelectedItem.Text);

            

            Response.Redirect(Request.RawUrl);
        }
    }
}